<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :customRow="customRow"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">
        <template slot="status" slot-scope="status">
          <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt=""
            style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <template v-if="!disabledButton">
            <a-button
              class="ruleButton"
              :ghost="true"
              type="primary"
              icon="edit"
              @click="handleEdit(record)"
              :disabled="isDisabledAuth('erpSealStatusChange:edit')"
            />
            <a-divider type="vertical"/>
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a-button
                class="ruleButton"
                :ghost="true"
                type="primary"
                icon="delete"
                :disabled="isDisabledAuth('erpSealStatusChange:delete')"/>
            </a-popconfirm>
          </template>
        </span>

      </a-table>
    </div>

    <erp-seal-status-change-modal ref="modalForm" @ok="modalFormOk"></erp-seal-status-change-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ErpSealStatusChangeModal from './modules/ErpSealStatusChangeModal'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'

export default {
  name: 'ErpSealStatusChangeList',
  mixins: [JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
  components: {
    ErpSealStatusChangeModal
  },
  props: {
    disabledButton: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      description: '印章状态变更信息管理页面',
      // 表头
      // 列设置
      settingColumns: [],
      // 列定义
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '编号',
          align: 'center',
          dataIndex: 'sealQualificationId',
        },
        {
          title: '名称',
          align: 'center',
          dataIndex: 'name',
        },
        {
          title: '类别',
          align: 'center',
          dataIndex: 'sealType_dictText',
        },
        {
          title: '经办人',
          align: 'center',
          // dataIndex: 'handlerId',
          dataIndex: 'handlerId_dictText',
        },
        {
          title: '经办人部门',
          align: 'center',
          // dataIndex: 'handlerDeptId',
          dataIndex: 'handlerDeptId_dictText',
        },
        {
          title: '变更类型',
          align: 'center',
          dataIndex: 'changType_dictText',
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'bpmStatus_dictText',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action'
          }
        }
      ],
      url: {
        list: '/api/erp/administration/seal/erpSealCertificationChangeRecord/list',
        delete: '/api/erp/administration/seal/erpSealCertificationChangeRecord/delete',
        deleteBatch: '/api/erp/administration/seal/erpSealCertificationChangeRecord/deleteBatch',
        exportXlsUrl: '/api/erp/administration/seal/erpSealCertificationChangeRecord/exportXls',
        importExcelUrl: 'administration/seal/erpSealCertificationChangeRecord/importExcel',
        bizCount: '/api/erp/administration/seal/erpSealCertificationChangeRecord/bizCount',
        startProcess: '/api/erpmng/act/process/extActProcess/startMutilProcess',
      },
      dictOptions: {},
      superFieldList: [],
      disableMixinCreated: true,
      colsettings: 'ErpSealStatusChange:colsettings'
    }
  },
  watch: {
    $route(to, from) {
      if (this.$route.params.id) {
        this.queryParam.baseId = this.$route.params.id
      }
      this.loadData();
    }
  },
  created() {
    if (this.$route.params.id) {
      this.queryParam.baseId = this.$route.params.id
    }
    this.loadData()
  },
  computed: {
  },
  methods: {
    handleAdd: function () {
      this.$refs.modalForm.edit({
        'mainId': this.$route.params.id
      })
      this.$refs.modalForm.title = '新增'
      this.$refs.modalForm.disableSubmit = false
    },

    // table 双击查看详情
    customRow(record) {
      return {
        on: {
          // 事件
          dblclick: event => {
            this.handleDetail(record)
          }
        }
      }
    },

    handleDetail (record) {
      this.$router.push({
        path: `/erp/administration/seal/ErpSealCertificationChangeRecordListDetail/${record.id}`
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
